//
//  GloableMacro.h
//  Learn
//
//  Created by icomexe on 2018/10/24.
//  Copyright © 2018年 cjg. All rights reserved.
//

#ifndef GloableMacro_h
#define GloableMacro_h

//*********************************//
//*           全局宏定义            *//
//*********************************//

#define kKeyWindow [UIApplication sharedApplication].keyWindow
//屏幕宽度
#define SCREEN_W [UIScreen mainScreen].bounds.size.width
//屏幕高度
#define SCREEN_H [UIScreen mainScreen].bounds.size.height
#define k_StatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height

#define appDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)

//手机版本名称
#define MODEL_NAME         [[UIDevice currentDevice] model]
#define MODEL_VERSION      [[[UIDevice currentDevice] systemVersion] floatValue]

//线条粗细
#define LineHeight (1.0/[UIScreen mainScreen].scale)

#define USERDEFAULTS [NSUserDefaults standardUserDefaults]

#define kWIDTH_RATIO              (CGRectGetWidth([[UIScreen mainScreen] bounds]) / 375)
#define kHEIGHT_RATIO             (CGRectGetHeight([[UIScreen mainScreen] bounds]) / 812)

// 是否是刘海屏
#define iPhoneX ({\
    BOOL isBangsScreen = NO; \
    if (@available(iOS 11.0, *)) { \
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
    isBangsScreen = window.safeAreaInsets.bottom > 0; \
    } \
    isBangsScreen; \
})

// 定义statusBar和navigationBar高度
#define NavigationBarHeight (iPhoneX ? 88 : 64)

// 定义iPhoneX非安全区域顶部部高度
#define SafeAreaTopHeight (iPhoneX ? 44.0f : 20.0f)

// 定义iPhoneX非安全区域底部高度
#define SafeAreaBottomHeight (iPhoneX ? 34.0f : 0.0f)

//角度单位
#define km_Radian(pi) (pi * M_PI / 180.0)

// 默认cell高度
#define HEIGHT_CELL48 48

#define DEFAULT_CORNER_RADIUS   8.0f

//空间间距
#define MARGIN_MIN          4
#define MARGIN_MIDDLE       10
#define MARGIN_MAX          20
#define MARGIN_BUTTON_TO_BOTTOM  ([UIDevice vg_safeDistanceBottom] + 60)
#define BLANK_40        40
#define BLANK_20        20
#define BLANK_10        10

//weakSelf
#define WS(WeakSelf) __weak __typeof(&*self)WeakSelf =self;
//__weak与__strong修饰
#define WeakSelf(type)  __weak typeof(type) weak##type = type;
#define StrongSelf(type)  __strong typeof(type) type = weak##type;
//字符串是否为空
#define IsStrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref)isEqualToString:@""]))
//数组是否为空
#define IsArrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref) count] == 0) || ![(_ref) isKindOfClass:[NSArray class]])

//debug打印
#ifdef DEBUG
#define DebugString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent
#define DebugLog(...) printf(" %s 第%d行: %s\n\n",[DebugString UTF8String] ,__LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String]);
#else
#define DebugLog(...)
#endif

#define CycLanguageNotification @"CycLanguageNotification"

#define CSMeterToMileage(value)     (value * 0.00062137)
#define CSFeetUnitString    @"feet"

#endif /* GloableMacro_h */
